<select class="form-control" name="province" id="J_province"></select>
<select class="form-control"  name="city" id="J_city" style="display:none;"></select>
<select class="form-control"  name="district" id="J_district" style="display:none;"></select>

<script type="text/javascript">

$(function(){

	var pid={if condition="$param.province neq ''"}{$param.province}{else /}0{/if};  //默认省份id
	var cid={if condition="$param.city neq ''"}{$param.city}{else /}0{/if};  //默认城市id
	var did={if condition="$param.district neq ''"}{$param.district}{else /}0{/if};  //默认区县市id

    /*修复联动不及时的bug，陈一枭*/
    function change_province(pid){
        $.post("{:addons_url('Chinacity://Chinacity/getProvince')}", {pid: pid}, function(result){
            $("#J_province").html(result);
        });
    }

    function change_city(p_pid,p_cid){
        $.post('{:addons_url("Chinacity://Chinacity/getCity")}', {pid: p_pid, cid: p_cid}, function(result){
            $("#J_city").show().html(result);
        });
    }

    function change_district(p_cid,p_did){
        $.post('{:addons_url("Chinacity://Chinacity/getDistrict")}', {cid: p_cid, did: p_did}, function(result){
            $("#J_district").show().html(result);
        });
    }

    change_province(pid);
    change_city(pid,cid);
    change_district(cid,did);

	$('#J_province').change(function(){
		var pid_g=$(this).children('option:selected').val();
		change_city(pid_g)
        change_district(0);
	});

	$('#J_city').change(function(){
		var cid_g=$(this).children('option:selected').val();
		change_district(cid_g)
	});

	$('#J_district').change(function(){
		var did_g=$(this).children('option:selected').val();
	});

});
/*修复联动不及时的bug，陈一枭end*/
</script>